import 'dart:io';

import 'package:bot_toast/bot_toast.dart';
import 'package:city_pickers/city_pickers.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:intl/intl.dart';
import 'package:shopping_group/base/base_constant.dart';
import 'package:shopping_group/entity/community_seletion_result_entity.dart';
import 'package:shopping_group/entity/rich_text_entity.dart';
import 'package:shopping_group/entity/selectiont_entity.dart';
import 'package:shopping_group/entity/widget_action_entity.dart';
import 'package:shopping_group/entity/widget_entity.dart';
import 'package:shopping_group/modle/main/ui/lz_preview_image_page.dart';
import 'package:shopping_group/res/colors.dart';
import 'package:shopping_group/res/dimens.dart';
import 'package:shopping_group/utils/route_util.dart';
import 'package:marquee_flutter/marquee_flutter.dart';
import 'clipboard_tool.dart';
import 'object_util.dart';
import 'utils.dart';

class WidgetUtils {
  static Widget getImageWidget(String name,
      {String format: 'png', BoxFit fit: BoxFit.fitWidth}) {
    return Container(
        decoration: BoxDecoration(
      image: DecorationImage(
        image: AssetImage(Utils.getImgPath(name, format: format)),
        fit: fit,
      ),
    ));
  }

  static Widget getImageAsset(String name,
      {String format: 'png', double width: 32.0, double height: 32.0}) {
    return Image.asset(
      Utils.getImgPath(name, format: format),
      width: width,
      height: height,
    );
  }

  static Widget getImageAssetWidget(String name,
      {String format: 'png', double size: 32.0}) {
    return Image.asset(
      Utils.getImgPath(Utils.reTextNull(name), format: format),
      width: size,
      height: size,
    );
  }

  static Widget getTextColorView(String text, Color color, var size,
      {TextAlign textAlign: TextAlign.start,
      fontweight: FontWeight.w400,
      decoration: TextDecoration.none,
      decorationColor: Colours.transparent,
      TextOverflow overflow: TextOverflow.clip,
      int maxLines: 2}) {
    return ObjectUtil.isEmptyString(text)
        ? Container()
        : Container(
            color: Colours.transparent,
            child: Text(
              text,
              softWrap: true,
              overflow: overflow,
              textAlign: textAlign,
              style: TextStyle(
                decoration: decoration,
                decorationColor: decorationColor,
                fontSize: size,
                color: color,
                fontWeight: fontweight,
              ),
            ),
          );
  }

  static Widget getTextMaxLinesView(String text, Color color, var size,
      {TextAlign textAlign: TextAlign.start,
      fontweight: FontWeight.w400,
      decoration: TextDecoration.none,
      decorationColor: Colours.transparent,
      TextOverflow overflow: TextOverflow.clip,
      int maxLines: 2}) {
    return ObjectUtil.isEmptyString(text)
        ? Container()
        : Container(
            child: Text(
              text,
              softWrap: true,
              maxLines: maxLines,
              overflow: overflow,
              textAlign: textAlign,
              style: TextStyle(
                decoration: decoration,
                decorationColor: decorationColor,
                fontSize: size,
                color: color,
                fontWeight: fontweight,
              ),
            ),
          );
  }

  static Widget getTextColorLineView(String text, Color color, var size) {
    return Container(
      child: Text(
        text,
        maxLines: 1,
        overflow: TextOverflow.ellipsis,
        style: TextStyle(
          // decoration: TextDecoration.none,
          fontSize: size,
          color: color,
        ),
      ),
    );
  }

  static Widget getRichTextView(List<RichTextEntity> list,
      {Function onCilekListener}) {
    return RichText(
      text: TextSpan(
        children: list.map((RichTextEntity entity) {
          return buildTextView(entity, onCilekListener); //赋值后的Widget
        }).toList(),
      ),
    );
  }

  static TextSpan buildTextView(
      RichTextEntity entity, Function onCilekListener) {
    return TextSpan(
      text: entity.title,
      recognizer: entity.tapGestureRecognizer
        ..onTap = () {
          if (null != onCilekListener) {
            onCilekListener(entity);
          }
        },
      style: TextStyle(
        backgroundColor: entity.backgroundColor,
        color: entity.textColor,
        fontSize: entity.size,
        fontWeight: entity.fontweight,
      ),
    );
  }

  static Widget getTextView(String text, var size) {
    return Container(
      child: Text(
        text,
        style: TextStyle(
          fontSize: size,
        ),
      ),
    );
  }

  static Widget getTextViewPading16(String text, var size) {
    return Container(
      padding: const EdgeInsets.only(left: 16),
      child: Text(
        text,
        style: TextStyle(
          fontSize: size,
        ),
      ),
    );
  }

  static Widget drawDivider8() {
    return Container(
        alignment: FractionalOffset.center,
        padding: const EdgeInsets.only(top: 8),
        child: Divider(
          height: 1.0,
          color: Color(0xFFF5F5F5),
        ));
  }

  static Widget drawDivider(
      {Color color: Colours.gray_f5, double height: 1.0}) {
    return Container(
        alignment: FractionalOffset.center,
        child: Divider(
          height: height,
          color: color,
        ));
  }

  static Widget drawCodeDivider(
      {Color color: Colours.gray_f5,
      double height: 2.0,
      double width: double.infinity}) {
    return Container(
      width: width,
      height: height,
      color: color,
    );
  }

  static Widget drawDividerMargin16({Color color: Colours.gray_f5}) {
    return Container(
        margin: const EdgeInsets.symmetric(horizontal: 16),
        alignment: FractionalOffset.center,
        child: Divider(
          height: 1.0,
          color: color,
        ));
  }

  static Widget drawVerticalDivider(
      {Color color: Colours.gray_f5, double height: 50, double width: 1}) {
    return Container(
      color: color,
      alignment: FractionalOffset.center,
      width: width,
      // height: height,
      child: VerticalDivider(color: color),
    );
  }

  static Widget drawVerticalContainer(
      {Color color: Colours.gray_f5, double height: 16, double width: 1}) {
    return Container(
      color: color,
      alignment: FractionalOffset.center,
      width: width,
      height: height,
      // child: VerticalDivider(color: color),
    );
  }

  static Widget buildLoginProgress() {
    return CircularProgressIndicator(
      valueColor: AlwaysStoppedAnimation<Color>(Colours.themeColor),
    );
  }

  static Widget buildTextField(
      TextEditingController controller,
      TextInputType type,
      String text,
      List<TextInputFormatter> list,
      IconData iconData,
      {bool isSecrecy: false,
      Color iconColor,
      Color textColor,
      Color hitColor}) {
    return Container(
        margin: const EdgeInsets.only(top: 10),
        padding: const EdgeInsets.only(top: 5, right: 5, bottom: 5),
        alignment: Alignment.center,
        height: 60.0,
        //  decoration: BoxDecoration(
        //      color: Colors.transparent,
        //      border: Border.all(color: Colours.themeColor, width: 1.0),
        //      borderRadius: BorderRadius.circular(12.0)),
        child: TextField(
          style: TextStyle(
            // backgroundColor:Colours.themeColor,
            color: null == textColor ? Colours.text_2222 : textColor,
            fontSize: 16.0,
          ),
          controller: controller,
          obscureText: isSecrecy,

          keyboardType: type,
          cursorColor: Colours.themeColor,
          decoration: InputDecoration(
//            contentPadding: EdgeInsets.all(10.0),
            border: InputBorder.none,
            prefixIcon: Icon(
              iconData,
              color: null == iconColor ? Colours.themeColor : iconColor,
              size: 24,
            ),
            hintText: text,
            hintStyle: TextStyle(
              color: null == textColor ? Colours.text_bd : textColor,
            ),

            //  hint: text,

//            labelText: text,
//            labelStyle: TextStyle(fontSize: 13.0, color: Colours.themeColor),
//            hintText: text,
          ),
          autofocus: false,
          inputFormatters: list,
          // onChanged: (str) => mProvide.username = str,
        ));
  }

  static Widget getTextFieldView(
    TextEditingController controller,
    String text, {
    double height: 40,
    double width: 60,
    bool isSecrecy: false,
    double hintFontSize: Dimens.FONT_SIZE_16,
    TextInputType type: TextInputType.phone,
  }) {
    return Container(
        padding: const EdgeInsets.only(left: 8),
        alignment: Alignment.center,
        // height: height,
        width: width,
        decoration: BoxDecoration(
            color: Colors.transparent,
            border: Border.all(color: Colours.transparent, width: 1.0),
            borderRadius: BorderRadius.circular(12.0)),
        child: TextField(
          style: TextStyle(
            // backgroundColor:Colours.themeColor,
            // color: Colours.themeColor,
            fontSize: hintFontSize,
          ),
          controller: controller,
          obscureText: isSecrecy,
          keyboardType: type,
          cursorColor: Colours.themeColor,
          decoration: InputDecoration(
//            contentPadding: EdgeInsets.all(10.0),
            border: InputBorder.none,
            hintText: text,
            hintStyle: TextStyle(
              color: Colours.text_bd,
              fontSize: hintFontSize,
            ),

            //  hint: text,

//            labelText: text,
//            labelStyle: TextStyle(fontSize: 13.0, color: Colours.themeColor),
//            hintText: text,
          ),
          autofocus: false,
          // onChanged: (str) => mProvide.username = str,
        ));
  }

  static Widget buildTextFieldTwo(TextEditingController controller,
      TextInputType type, String text, List<TextInputFormatter> list,
      {double height: 60}) {
    return Container(
        alignment: Alignment.center,
        height: height,
        decoration: BoxDecoration(
            color: Colours.gray_f0,
            border: Border.all(color: Colours.gray_f0, width: 1.0),
            borderRadius: BorderRadius.circular(12.0)),
        child: TextField(
          textAlign: TextAlign.center,
          style: TextStyle(
            fontSize: 14.0,
          ),
          controller: controller,
          keyboardType: type,
          cursorColor: Colours.themeColor,
          decoration: InputDecoration(
            contentPadding: EdgeInsets.only(top: 1),
            border: InputBorder.none,
            hintText: text,
            hintStyle: TextStyle(
              fontSize: 13.0,
            ),
          ),
          autofocus: false,
          inputFormatters: list,
          onChanged: (v) {},
        ));
  }

  static Widget buildTextFieldCode(
      TextEditingController controller,
      TextInputType type,
      String text,
      List<TextInputFormatter> list,
      String codeCountdownStr,
      Color colorStr,
      {Function codeCallback,
      Color hitColor,
      Color textColor,
      Color colorBorder: Colours.blackground_e00,
      Color colorBox: Colours.blackground_25e00}) {
    return Container(
        padding: const EdgeInsets.all(0),
        alignment: Alignment.center,
        height: 50.0,
//        decoration: BoxDecoration(
//            color: Colors.transparent,1
//            border: Border.all(color: Colours.themeColor, width: 1.0),
//            borderRadius: BorderRadius.circular(12.0)),
        child: Row(
          children: <Widget>[
            Expanded(
              child: TextField(
                style: TextStyle(
                    fontSize: 18.0,
                    color: null == textColor ? Colours.gray_91 : textColor),
                controller: controller,
                keyboardType: type,
                cursorColor: Theme.of(RouteUtil.navigatorKey.currentContext)
                    .primaryColor,

                decoration: InputDecoration(
//                  contentPadding: EdgeInsets.all(10.0),
                  border: InputBorder.none,
                  hintText: text,
                  hintStyle: TextStyle(
                      fontSize: 18.0,
                      color: null == hitColor ? Colours.gray_91 : hitColor),
                ),
                // autofocus: false,
                inputFormatters: list,
                // onChanged: (str) => mProvide.username = str,
              ),
              flex: 1,
            ),
            GestureDetector(
              onTap: (() {
                codeCallback(codeCountdownStr);
              }),
              child: Container(
                alignment: Alignment.center,
                height: 42,
                padding: EdgeInsets.symmetric(horizontal: 16),
                decoration: BoxDecoration(
                    color: colorBox,
                    border: Border.all(color: colorBorder, width: 1.0),
                    borderRadius: BorderRadius.circular(25.0)),
                child: getTextColorView(
                    codeCountdownStr, colorStr, Dimens.FONT_SIZE_14),
              ),
            ),
            SizedBox(
              width: 16,
            ),
          ],
        ));
  }

  static PreferredSizeWidget showAppar(
    BuildContext context,
    String title, {
    // Color backgroundColor: Colours.themeColor,
    Color leadingColor: Colors.white,
    Color textColor: Colors.white,
    double textSize: Dimens.FONT_SIZE_20,
    List<WidgetActionEntity> actionList,
    Function onTapCall,
    bool isHide: false,
    TabController tabController,
    List<WidgetActionEntity> tabList,
    Color backgroundColor,
    Function onTapClose,
  }) {
    return AppBar(
      leading: IconButton(
        icon: Icon(
          Icons.arrow_back_ios,
          color: leadingColor,
          size: 16,
        ),
        onPressed: () {
          null == onTapClose ? RouteUtil.closeView() : onTapClose();
        },
      ),
      elevation: 0.0,
      backgroundColor: null == backgroundColor
          ? Theme.of(context).primaryColor
          : backgroundColor,
      title: WidgetUtils.getTextColorView(title, textColor, textSize),
      centerTitle: true,
      bottom: ObjectUtil.isEmptyList(tabList)
          ? null
          : TabBar(
              // isScrollable: true, //tab是否可滚动，
              indicatorWeight: 2, //指示器高度
              indicatorSize: TabBarIndicatorSize.label, //和字体等宽，或者和tab等宽
              indicatorPadding: EdgeInsets.only(top: 60), //下划线间距
              indicatorColor: Colours.title_white,
              labelStyle: TextStyle(
                fontSize: Dimens.FONT_SIZE_16,
              ),
              tabs: tabList.map((WidgetActionEntity entity) {
                return getTabView(entity);
              }).toList(),
              controller: tabController,
            ),
      actions: ObjectUtil.isEmptyList(actionList)
          ? List()
          : actionList.map((WidgetActionEntity entity) {
              return _getAppbarView(entity,
                  onTapCall: onTapCall, isHide: isHide);
            }).toList(),
    );
  }

  static Widget getTabView(WidgetActionEntity entity) {
    return Tab(
      text: entity.title,
      // child: getTextColorView(entity.title, Colours.title_white, Dimens.FONT_SIZE_16),
    );
  }

  static PreferredSizeWidget showApparNotLeading(
      BuildContext context, String title,
      {
      // Color backgroundColor: Colours.title_white,
      Color leadingColor: Colours.text_2222,
      Color textColor: Colours.text_2222,
      double textSize: Dimens.FONT_SIZE_20,
      bool isHide: true,
      bool isCenterTitle: true,
      List<WidgetActionEntity> actionList,
      Function onTapCall}) {
    return AppBar(
      // automaticallyImplyLeading: false,
      // leading:  IconButton(
      //     icon: Icon(
      //       Icons.arrow_back_ios,
      //       color: leadingColor,
      //       size: 16,
      //     ),
      //     onPressed: () {
      //       RouteUtil.closeView(context);
      //     },
      //   ),
      automaticallyImplyLeading: false,
      elevation: 0.0,
      backgroundColor: Theme.of(context).primaryColor,
      title: WidgetUtils.getTextColorView(title, textColor, textSize),
      centerTitle: isCenterTitle,
      actions: ObjectUtil.isEmptyList(actionList)
          ? List()
          : actionList.map((WidgetActionEntity entity) {
              return _getAppbarView(entity,
                  onTapCall: onTapCall, isHide: isHide); //赋值后的Widget
            }).toList(),
    );
  }

  static Widget _getAppbarView(WidgetActionEntity entity,
      {Function onTapCall, bool isHide}) {
    return isHide
        ? Container()
        : Container(
            padding: const EdgeInsets.only(right: 16),
            alignment: FractionalOffset.center,
            child: GestureDetector(
              onTap: () {
                if (null == onTapCall) {
                  return;
                }
                onTapCall(entity);
              },
              child: showActionView(entity),
            ));
  }

  static Widget showActionView(WidgetActionEntity entity) {
    Widget actionView;
    // LogUtil.e(entity.actionType, tag: 'entity.......');
    if (ObjectUtil.isEmpty(entity.actionType)) {
      if (null != entity.iconData) {
        entity.actionType = 'icon';
      } else {
        entity.actionType = 'text';
      }
    }
    switch (entity.actionType) {
      case 'icon':
        actionView = Icon(
          entity.iconData,
          color: Colors.white,
          size: entity.size,
        );
        break;
      case 'image':
        actionView = Row(
          children: <Widget>[
            getImageAsset(entity.image),
            getTextColorView(entity.title, entity.actionColor,
                0 == entity.titleSize ? Dimens.FONT_SIZE_14 : entity.titleSize),
          ],
        );
        break;
      case 'text':
        actionView = getTextColorView(entity.title, entity.actionColor,
            0 == entity.titleSize ? Dimens.FONT_SIZE_14 : entity.titleSize);
        break;
      case 'menu':
        actionView = Row(
          children: <Widget>[
            getTextColorView(entity.title, entity.actionColor,
                0 == entity.titleSize ? Dimens.FONT_SIZE_14 : entity.titleSize),
            Icon(
              entity.iconData,
              color: Colors.white,
              size: 14,
            ),
          ],
        );
        break;
      case 'image_and_text':
        break;
      default:
    }
    return actionView;
  }

  static Widget showBoxBotton(String title,
      {Color borderColor: Colors.transparent,
      Color boxColor: Colors.transparent,
      Color textColor: Colours.text_2222,
      double textSize: Dimens.FONT_SIZE_16,
      double textPadding: 5,
      double horizontalPadding: 4,
      TextOverflow overflow: TextOverflow.clip,
      double borderRadius: 15.0}) {
    return Container(
        padding:
            EdgeInsets.symmetric(horizontal: horizontalPadding, vertical: 2.0),
        decoration: BoxDecoration(
            border: Border.all(color: borderColor, width: 1.0),
            borderRadius: BorderRadius.circular(borderRadius),
            color: boxColor),
        child: Padding(
          padding: EdgeInsets.all(textPadding),
          child: WidgetUtils.getTextColorView(title, textColor, textSize,
              overflow: overflow),
        ));
  }

  static Widget showWidthBoxBotton(String title,
      {Color borderColor: Colors.transparent,
      Color boxColor: Colors.transparent,
      Color textColor: Colours.text_2222,
      double textSize: Dimens.FONT_SIZE_16,
      TextOverflow overflow: TextOverflow.clip,
      double borderRadius: 10.0}) {
    return Container(
        width: MediaQuery.of(RouteUtil.navigatorKey.currentContext).size.width,
        padding: EdgeInsets.symmetric(horizontal: 4.0, vertical: 8.0),
        margin: EdgeInsets.symmetric(horizontal: 4.0, vertical: 0.0),
        decoration: BoxDecoration(
            border: Border.all(color: borderColor, width: 1.0),
            borderRadius: BorderRadius.circular(borderRadius),
            color: boxColor),
        child: Padding(
          padding: const EdgeInsets.all(5),
          child: WidgetUtils.getTextColorView(title, textColor, textSize,
              overflow: overflow),
        ));
  }

  static Widget buildScrollview(List<String> listPhoto,
      {double width: 64, double height: 64, Function onTopCallBlack}) {
    return SingleChildScrollView(
      //滑动的方向 Axis.vertical为垂直方向滑动，Axis.horizontal 为水平方向
      scrollDirection: Axis.horizontal,
      //true 滑动到底部
      reverse: false,
      padding: EdgeInsets.all(0.0),
      //滑动到底部回弹效果
      physics: BouncingScrollPhysics(),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: listPhoto.map((String path) {
          return buildGridView(path,
              width: width,
              height: height,
              onTopCallBlack: onTopCallBlack); //赋值后的Widget
        }).toList(),
      ),
    );
  }

  static Widget buildGridViewWidget(List<String> listPhoto) {
    return Container(
      padding:
          EdgeInsets.symmetric(horizontal: 16).add(EdgeInsets.only(top: 16)),
      child: GridView.builder(
        padding: EdgeInsets.zero,
        controller: ScrollController(keepScrollOffset: false), //靜止滾動事件
        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
            crossAxisCount: 3,
            crossAxisSpacing: 11,
            mainAxisSpacing: 11,
            childAspectRatio: 1 / 1), //子纵比例
        shrinkWrap: true, //收缩包装
        itemBuilder: (context, index) {
          return GestureDetector(
            onTap: () {
              RouteUtil.goParameter(EcPreviewPhotoViewPage(
                listPhoto,
                currentIndex: index,
              ));
            },
            child: Container(
              decoration: BoxDecoration(
                color: Colors.white,
                //设置四周圆角 角度
                borderRadius: BorderRadius.circular(12),
              ),
              child: FadeInImage.assetNetwork(
                image: listPhoto[index],
                placeholder: 'images/picture_loading.png' /* 指定gif */,
                fit: BoxFit.cover,
              ),
            ),
          );
        },
        itemCount: listPhoto.length,
      ),
    );
  }

  static Widget buildGridView(String path,
      {double width: 64, double height: 64, Function onTopCallBlack}) {
    return Stack(
      alignment: const FractionalOffset(1, 0),
      children: <Widget>[
        GestureDetector(
          onTap: () {
            if (null == onTopCallBlack) {
              return;
            }
            onTopCallBlack(path);
          },
          child: Container(
              width: width,
              height: height,
              margin: const EdgeInsets.all(5.0),
              child: Material(
                borderRadius: BorderRadius.circular(0.0),
                shadowColor: Colors.blue.shade200,
                color: Colors.white,
                elevation: 0.0,
                child: FadeInImage.assetNetwork(
                  image: path,
                  placeholder: 'images/picture_loading.png' /* 指定gif */,
                  fit: BoxFit.cover,
                ),
              )),
        ),
      ],
    );
  }

  static Widget buildNetworkImageView(String path,
      {double width: 64, double height: 64}) {
    path = ObjectUtil.isEmptyString(path) ? '' : path;
    return Stack(
      children: <Widget>[
        Container(
            width: width,
            height: height,
            margin: const EdgeInsets.all(5.0),
            child: Material(
              borderRadius: BorderRadius.circular(0.0),
              shadowColor: Colors.blue.shade200,
              color: Colors.white,
              elevation: 0.0,
              child: FadeInImage.assetNetwork(
                image: path,
                placeholder: 'images/picture_loading.png' /* 指定gif */,
                fit: BoxFit.cover,
              ),
            )),
      ],
    );
  }

  static Widget itmeStyleView(String title, String content,
      {bool isShow: true,
      Color contentColor: Colours.text_33,
      Alignment contentAlignment: Alignment.centerLeft,
      double textSize: Dimens.FONT_SIZE_16,
      Color textColor: Colours.text_2222,
      double verticalPadding: 12,
      double left: 16,
      double right: 16,
      double bewteenleft: 0,
      bool isExpanded: true,
      bool isContentExpanded: false,
      bool isShowText: false,
      int titleExpanded: 1,
      int contentExpanded: 2,
      int contentMaxline: 2,
      FontWeight titleFontweight: FontWeight.w400,
      TextAlign textAlign: TextAlign.start,
      TextOverflow contentOverflow: TextOverflow.clip,
      Function callBlack}) {
    return Container(
      alignment: Alignment.centerLeft,
      margin: EdgeInsets.only(
          right: right,
          left: left,
          top: verticalPadding,
          bottom: verticalPadding),
      child: isExpanded
          ? Row(
              // mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                titleExpanded == 0
                    ? GestureDetector(
                        onTap: () {
                          if (null != callBlack) {
                            callBlack();
                          }
                        },
                        child: WidgetUtils.getTextColorView(
                            title, textColor, textSize))
                    : Expanded(
                        child: GestureDetector(
                          onTap: () {
                            if (null != callBlack) {
                              callBlack();
                            }
                          },
                          child: WidgetUtils.getTextColorView(
                              title, textColor, textSize,
                              fontweight: titleFontweight),
                        ),
                        flex: titleExpanded,
                      ),
                Expanded(
                  child: ObjectUtil.isEmpty(content)
                      ? Container()
                      : GestureDetector(
                          onTap: () {
                            if (null != callBlack) {
                              callBlack();
                            }
                          },
                          child: Container(
                            color: Colours.transparent,
                            alignment: contentAlignment,
                            margin: EdgeInsets.only(left: bewteenleft),
                            child: WidgetUtils.getTextColorView(
                                content, contentColor, textSize,
                                textAlign: textAlign,
                                overflow: contentOverflow,
                                maxLines: contentMaxline),
                            // padding: const EdgeInsets.only(left: 16),
                          ),
                        ),
                  flex: contentExpanded,
                ),
                Offstage(
                  offstage: isShow,
                  child: Container(
                    padding: const EdgeInsets.only(left: 8),
                    child: Icon(
                      Icons.keyboard_arrow_right,
                      color: Colours.themeColor,
                    ),
                  ),
                ),
              ],
            )
          : Row(
              mainAxisAlignment: MainAxisAlignment.start,
              children: <Widget>[
                WidgetUtils.getTextColorView(
                  title,
                  textColor,
                  textSize,
                  fontweight: titleFontweight,
                ),
                ObjectUtil.isEmpty(content)
                    ? Container()
                    : (isContentExpanded
                        ? Expanded(
                            child: Container(
                              alignment: contentAlignment,
                              child: WidgetUtils.getTextColorView(
                                  content, contentColor, textSize,
                                  textAlign: textAlign,
                                  overflow: contentOverflow,
                                  maxLines: contentMaxline),
                              margin: EdgeInsets.only(left: bewteenleft),
                            ),
                          )
                        : Container(
                            alignment: contentAlignment,
                            child: WidgetUtils.getTextColorView(
                                content, contentColor, textSize,
                                textAlign: textAlign,
                                overflow: contentOverflow,
                                maxLines: contentMaxline),
                            margin: EdgeInsets.only(left: bewteenleft),
                          )),
                Offstage(
                  offstage: isShow,
                  child: isShowText
                      ? GestureDetector(
                          onTap: () {
                            ClipboardTool.setDataToastMsg(content,
                                toastMsg: "已复制到剪贴板");
                            //已复制到剪贴板
                          },
                          child: Container(
                            alignment: Alignment.centerRight,
                            padding: const EdgeInsets.symmetric(horizontal: 8),
                            child: WidgetUtils.getTextColorView(
                              (content != null && content.length > 0)
                                  ? '复制'
                                  : "",
                              Colours.themeColor,
                              Dimens.FONT_SIZE_14,
                            ),
                          ),
                        )
                      : Container(
                          padding: const EdgeInsets.only(left: 8),
                          child: Icon(
                            Icons.keyboard_arrow_right,
                            color: Colours.themeColor,
                          ),
                        ),
                ),
              ],
            ),
    );
  }

  static Widget boxChangeBotton(String title, bool isSoild,
      {Color soildColor: Colors.transparent,
      // Color boxColor: Colours.themeColor,
      Color textColor: Colours.text_2222,
      double textSize: Dimens.FONT_SIZE_13,
      Function onTapCall}) {
    return GestureDetector(
      onTap: (() {
        if (!isSoild) {
          isSoild = true;
        }
        if (null == onTapCall) {
          return;
        }
        onTapCall(isSoild);
      }),
      child: Container(
          padding: EdgeInsets.symmetric(horizontal: 4.0, vertical: 2.0),
          decoration: BoxDecoration(
              color: isSoild ? Colours.themeColor : Colors.transparent,
              border: Border.all(color: Colours.themeColor, width: 1.0),
              borderRadius: BorderRadius.circular(5.0)),
          child: Padding(
            padding: const EdgeInsets.all(5),
            child: Center(
              child: WidgetUtils.getTextColorView(
                  title,
                  isSoild
                      ? Colors.white
                      : Theme.of(RouteUtil.navigatorKey.currentContext)
                          .primaryColor,
                  textSize),
            ),
          )),
    );
  }

  static Widget boxChangeAutoBotton(String title, bool isSoild,
      {Color soildColor: Colors.transparent,
      // Color boxColor: Colours.themeColor,
      Color textColor: Colours.text_2222,
      double textSize: Dimens.FONT_SIZE_13,
      Function onTapCall}) {
    return GestureDetector(
      onTap: (() {
        if (isSoild) {
          isSoild = false;
        } else {
          isSoild = true;
        }
        if (null == onTapCall) {
          return;
        }
        onTapCall(isSoild);
      }),
      child: Container(
          padding: EdgeInsets.symmetric(horizontal: 4.0, vertical: 2.0),
          decoration: BoxDecoration(
              color: isSoild ? Colours.themeColor : Colours.gray_f0,
              border: Border.all(
                  color: isSoild
                      ? Theme.of(RouteUtil.navigatorKey.currentContext)
                          .primaryColor
                      : Colours.gray_f0,
                  width: 1.0),
              borderRadius: BorderRadius.circular(15.0)),
          child: Padding(
            padding: const EdgeInsets.all(5),
            child: Center(
              child: WidgetUtils.getTextColorView(
                  title, isSoild ? Colors.white : Colours.text_2222, textSize),
            ),
          )),
    );
  }

  static Widget lineView() {
    return Container(
        margin: const EdgeInsets.symmetric(vertical: 8.0),
        decoration: BoxDecoration(
          color: Colours.gray_f0,
          border: Border.all(color: Colours.gray_f0, width: 4.0),
          borderRadius: BorderRadius.horizontal(),
        ));
  }

  static Widget showItmeView(String title, String content,
      {String iocn: 'picture_loading',
      bool isShow: true,
      Color contentColor: Colours.text_33,
      double contentSize: Dimens.FONT_SIZE_16,
      double parmSize: Dimens.FONT_SIZE_16,
      // Color parmColor: Colours.themeColor,
      bool isHide: false}) {
    return Padding(
        padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            WidgetUtils.getImageAssetWidget(iocn),
            Padding(
                padding: const EdgeInsets.only(left: 16),
                child: WidgetUtils.getTextColorView(
                    title, contentColor, contentSize)),
            Expanded(
              child: Container(),
            ),
            WidgetUtils.getTextColorView(content, Colours.themeColor, parmSize),
            !isHide
                ? WidgetUtils.getImageAssetWidget('system_moreb')
                : Container(
                    width: 24,
                  ),
          ],
        ));
  }

  static Widget showIocnView(String title,
      {String iocn: 'picture_loading',
      String content: '无',
      bool isShow: true,
      Color contentColor: Colours.text_33,
      double contentSize: Dimens.FONT_SIZE_16,
      double parmSize: Dimens.FONT_SIZE_16,
      // Color parmColor: Colours.themeColor,
      double size: 32,
      bool isHide: false}) {
    return Padding(
        padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            WidgetUtils.getTextColorView(title, contentColor, contentSize),
            Expanded(
              child: Container(),
            ),
            !isHide
                ? WidgetUtils.clipRRectNetWorkImage(iocn)
                : WidgetUtils.getTextColorView(
                    content,
                    Theme.of(RouteUtil.navigatorKey.currentContext)
                        .primaryColor,
                    parmSize),
          ],
        ));
  }

  static Widget showTextField({
    int maxLines: 3,
    // int minLines: 3,
    int maxLength: 200,
    double hintSize: Dimens.FONT_SIZE_14,
    String hintText: '',
    TextEditingController controller,
    bool enabled: true,
    // Color focusedBorderColor: Colours.themeColor
  }) {
    return TextField(
      controller: controller,
      enabled: enabled,

      maxLength: maxLength,
      maxLines: maxLines,
      // minLines: minLines,

      decoration: InputDecoration(
        enabledBorder: OutlineInputBorder(
          /*边角*/
//                borderRadius: BorderRadius.all(
//                  Radius.circular(30), //边角为30
//                ),
          borderSide: BorderSide(
            color: Colors.transparent, //边线颜色为黄色
            width: 1, //边线宽度为2
          ),
        ),

        focusedBorder: OutlineInputBorder(
            borderSide: BorderSide(
          color: Theme.of(RouteUtil.navigatorKey.currentContext)
              .primaryColor, //边框颜色为绿色
          width: 3, //宽度为5
        )),
        // errorText: "errorText",

        hintText: hintText,
        hintStyle: TextStyle(
          fontSize: hintSize,
        ),
      ),
    );
  }

  static Widget showResultTextField(TextEditingController controller,
      {int minLines: 3,
      int maxLines: 10,
      int maxLength: 200,
      String hintText: '',
      double hintSize: Dimens.FONT_SIZE_14,
      Color focusedBorderColor: Colours.greed_66c}) {
    return TextField(
      controller: controller,
      maxLines: maxLines,
      maxLength: maxLength,
      minLines: minLines,
      decoration: InputDecoration(
        enabledBorder: OutlineInputBorder(
          /*边角*/
//                borderRadius: BorderRadius.all(
//                  Radius.circular(30), //边角为30
//                ),
          borderSide: BorderSide(
            color: Colours.gray_f5, //边线颜色为黄色
            width: 1, //边线宽度为2
          ),
        ),
        focusedBorder: OutlineInputBorder(
            borderSide: BorderSide(
          color: focusedBorderColor, //边框颜色为绿色
          width: 5, //宽度为5
        )),
        // errorText: "errorText",
        hintText: hintText,
        hintStyle: TextStyle(
          fontSize: hintSize,
        ),
      ),
    );
  }

//画圆
  static Widget clipRRect(
      {double circular: 50,
      double width: 18,
      double height: 18,
      Color color: Colors.red,
      String text}) {
    return ClipRRect(
      borderRadius: BorderRadius.circular(circular),
      child: Container(
        alignment: FractionalOffset.center,
        width: width,
        height: height,
        color: color,
        child: getTextColorView(text, Colors.white, Dimens.FONT_SIZE_10),
      ),
    );
  }

//圆形图片
  static Widget clipRRectNetWorkImage(
    String path, {
    double circular: 50,
    double width: 32,
    double height: 32,
    Color color: Colors.transparent,
  }) {
    return ClipRRect(
      borderRadius: BorderRadius.circular(circular),
      child: Container(
        alignment: FractionalOffset.center,
        width: width,
        height: height,
        color: color,
        child: Center(
            child: FadeInImage.assetNetwork(
          image: path,
          placeholder: 'images/picture_loading.png' /* 指定gif */,
        )),
      ),
    );
  }

  static Widget showEditText(WidgetEntity widgetEntity,
      {bool isSecrecy: false,
      int flexOne: 1,
      int flexTwo: 2,
      Alignment titleAlignment,
      Function onChangedText}) {
    TextInputType inputType = BaseConstant.textInputTypeAll;
    switch (widgetEntity.inputType) {
      case 'all':
      case 'none':
        inputType = BaseConstant.textInputTypeAll;
        break;
      case 'number':
        inputType = BaseConstant.textInputTypeNumber;
        break;
      case 'emil':
        inputType = TextInputType.emailAddress;
        break;
    }
    return Container(
      padding: const EdgeInsets.only(top: 2, bottom: 2),
      color: Colors.white,
      child: Column(
        children: <Widget>[
          Row(
            children: <Widget>[
              ObjectUtil.isEmptyString(widgetEntity.title)
                  ? Container()
                  : Expanded(
                      child: Container(
                        padding: const EdgeInsets.only(left: 16),
                        alignment: null == titleAlignment
                            ? Alignment.centerLeft
                            : titleAlignment,
                        child: getTextColorView(widgetEntity.title,
                            Colours.text_2222, Dimens.FONT_SIZE_16),
                      ),
                      flex: flexOne,
                    ),
              Expanded(
                child: Padding(
                  padding: const EdgeInsets.only(left: 8),
                  child: showTextFieldMx(
                      widgetEntity.hitTitle, inputType, widgetEntity.controller,
                      isSecrecy: isSecrecy, onChangedText: onChangedText),
                ),
                flex: flexTwo,
              ),
            ],
          ),
          drawDivider(),
        ],
      ),
    );
  }

  static Widget showTextFieldMx(
      String hitTitle, TextInputType type, TextEditingController controller,
      {bool isSecrecy: false,
      Function onChangedText,
      List<TextInputFormatter> list}) {
    return TextField(
      keyboardType: type,
      inputFormatters: (type == BaseConstant.textInputTypeAll)
          ? []
          : [BaseConstant.inputTypeFolat],
      controller: controller,
      decoration: InputDecoration(
        enabledBorder: OutlineInputBorder(
          borderSide: BorderSide(
            color: Colors.white, //边线颜色为黄色
            width: 1, //边线宽度为2
          ),
        ),
        focusedBorder: OutlineInputBorder(
            borderSide: BorderSide(
          color: Colors.white, //边框颜色为绿色
          width: 3, //宽度为5
        )),
        contentPadding: EdgeInsets.all(10.0),
        hintText: hitTitle,
      ),
      autofocus: false,
      obscureText: isSecrecy,
      onChanged: (v) {
        onChangedText(v);
      },
    );
  }

  static Widget showBaseInfoView(String title) {
    return Column(
      children: <Widget>[
        Container(
          padding: const EdgeInsets.symmetric(
            horizontal: 16,
            vertical: 5,
          ),
          color: Colours.gray_f0,
          alignment: FractionalOffset(0, 0),
          child: getTextColorView(title, Colours.text_91, Dimens.FONT_SIZE_13),
        ),
      ],
    );
  }

  static WidgetEntity initEditText(String title, String content,
      String hitTitle, String inoutType, TextEditingController controller) {
    WidgetEntity widgetEntity = WidgetEntity();
    widgetEntity.title = title;
    widgetEntity.editTextContent = content;
    widgetEntity.hitTitle = hitTitle;
    widgetEntity.inputType = inoutType;
    widgetEntity.controller = controller;
    controller.text = content;
    widgetEntity.type = 'EditText';
    widgetEntity.fristValue = Utils.reTextNull(content);
    return widgetEntity;
  }

  static Widget imageGallers(String title, List<String> list) {
    return Container(
      margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
      child: Row(
        children: <Widget>[
          WidgetUtils.getTextColorView(
              title, Colours.text_cc, Dimens.FONT_SIZE_16),
          Expanded(
            child: Container(
              alignment: FractionalOffset(1, 0),
              padding: const EdgeInsets.only(left: 16),
              child: WidgetUtils.buildScrollview(list),
            ),
          ),
        ],
      ),
    );
  }

//背景加文字
  static Widget periodicityDate(String title,
      {
      // Color backgroundColor: Colours.blackground_02,
      double padding: 3,
      Color textColor: Colors.white,
      double textSize: Dimens.FONT_SIZE_10}) {
    return Container(
      decoration: BoxDecoration(
        color: Colours.themeColor,
      ),
      padding: EdgeInsets.all(padding),
      child: WidgetUtils.getTextColorView(title, textColor, textSize),
    );
  }

  static Widget _changeView(List<WidgetEntity> _list,
      {Function cupertinoCall}) {
    return Container(
      margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
      child: Row(
        children: _list.map((WidgetEntity entity) {
          return _getItemContainer(entity, cupertinoCall: cupertinoCall);
        }).toList(),
      ),
    );
  }

  static Widget _getItemContainer(WidgetEntity entity,
      {Function cupertinoCall}) {
    return Expanded(
      child: Offstage(
        child: Container(
          margin: const EdgeInsets.only(right: 8),
          child: WidgetUtils.boxChangeAutoBotton(entity.title, entity.isSelect,
              onTapCall: (data) {
            cupertinoCall(entity, data);
          }),
        ),
        offstage: entity.title.isEmpty ? true : false,
      ),
      flex: 1,
    );
  }

  static Widget showSpinner(WidgetEntity widgetEntity,
      {Function stateCallback}) {
    return Container(
        color: Colors.white,
        alignment: FractionalOffset.centerLeft,
        child: Column(
          children: <Widget>[
            ObjectUtil.isEmptyString(widgetEntity.title)
                ? showSpinnerView(widgetEntity, stateCallback: stateCallback)
                : Row(
                    children: <Widget>[
                      Expanded(
                        child: Padding(
                          padding: const EdgeInsets.only(left: 16),
                          child: getTextColorView(widgetEntity.title,
                              Colours.text_2222, Dimens.FONT_SIZE_16),
                        ),
                        flex: 1,
                      ),
                      Expanded(
                        child: Padding(
                          padding: const EdgeInsets.only(left: 16),
                          child: showSpinnerView(widgetEntity,
                              stateCallback: stateCallback),
                        ),
                        flex: 2,
                      ),
                    ],
                  ),
            drawDivider(),
          ],
        ));
  }

  static Widget showSpinnerView(WidgetEntity widgetEntity,
      {Function stateCallback}) {
    //LogUtil.e(widgetEntity.spinnerValue, tag: 'showSpinnerView.....');
    List<CommunitySeletionResultEntity> pdsEntityList =
        List<CommunitySeletionResultEntity>.from(widgetEntity.spinnerList);
    List<DropdownMenuItem> list = WidgetUtils.getListData(pdsEntityList);
    return DropdownButton(
      items: list,
      underline: Container(),
      hint: getTextColorView('请选择', Colours.text_2222, Dimens.FONT_SIZE_16),
      //当没有默认值的时候可以设置的提示
      value: widgetEntity.spinnerValue,
      //下拉菜单选择完之后显示给用户的值
      onChanged: (T) {
        //下拉菜单item点击之后的回调
        stateCallback(T);
      },
      isExpanded: true,
      // elevation: 24,
      //设置阴影的高度
      style: TextStyle(
          //设置文本框里面文字的样式
          color: Colours.text_2222),
//              isDense: false,//减少按钮的高度。默认情况下，此按钮的高度与其菜单项的高度相同。如果isDense为true，则按钮的高度减少约一半。 这个当按钮嵌入添加的容器中时，非常有用
      // iconSize: 50.0,//设置三角标icon的大小);
    );
  }

  static Widget showDateTimeView(
      WidgetEntity widgetEntity, BuildContext context,
      {Function stateCallback}) {
    return Container(
      padding: const EdgeInsets.only(top: 1),
      color: Colors.white,
      alignment: FractionalOffset.centerLeft,
      child: Column(
        children: <Widget>[
          Flex(
            direction: Axis.horizontal,
            children: <Widget>[
              Expanded(
                child: Padding(
                  padding: const EdgeInsets.only(left: 16, bottom: 1),
                  child: getTextColorView(widgetEntity.title, Colours.text_2222,
                      Dimens.FONT_SIZE_16),
                ),
                flex: 1,
              ),
              Expanded(
                child: Padding(
                  padding: const EdgeInsets.only(bottom: 1),
                  child: selectDatePicker(widgetEntity, context,
                      stateCallback: stateCallback),
                ),
                flex: 2,
              ),
            ],
          ),
          drawDivider(),
        ],
      ),
    );
  }

  static Widget selectDatePicker(
      WidgetEntity widgetEntity, BuildContext context,
      {Function stateCallback}) {
    Widget widget =
        selectYearDate(widgetEntity, context, stateCallback: stateCallback);
    return widget;
  }

  static Widget selectYearDate(WidgetEntity widgetEntity, BuildContext context,
      {Function stateCallback}) {
    return FlatButton(
      onPressed: () {
        // String dateForm = 'yyyy';
        // DateTimePickerMode pickerMode = DateTimePickerMode.date;
        // switch (widgetEntity.dateTimeType) {
        //   case 'year':
        //     dateForm = 'yyyy';
        //     break;
        //   case 'month':
        //     dateForm = 'yyyy,MM';
        //     break;
        //   case 'day':
        //     dateForm = 'yyyy,MM,dd';
        //     break;
        //   case 'hour':
        //     dateForm = 'yyyy-MM-dd HH:mm';
        //     pickerMode = DateTimePickerMode.datetime;
        //     break;
        //   default:
        // }
        // DatePicker.showDatePicker(context,
        //     minDateTime: DateTime(1970),
        //     maxDateTime: DateTime(2025),
        //     locale: DateTimePickerLocale.zh_cn,
        //     pickerMode: pickerMode,
        //     dateFormat: dateForm, onConfirm: (date, selectedIndex) {
        //   StringBuffer stringBuffer = new StringBuffer();
        //   if (widgetEntity.dateTimeType == 'year') {
        //     stringBuffer.write(date.year.toString());
        //   } else if (widgetEntity.dateTimeType == 'month') {
        //     String monthStr = date.month.toString();
        //     if (monthStr.length == 1) {
        //       monthStr = '0' + date.month.toString();
        //     }
        //     stringBuffer..write(date.year)..write('-')..write(monthStr);
        //   } else if (widgetEntity.dateTimeType == 'day') {
        //     String monthStr = date.month.toString();
        //     if (monthStr.length == 1) {
        //       monthStr = '0' + date.month.toString();
        //     }
        //     String dayStr = date.day.toString();
        //     if (dayStr.length == 1) {
        //       dayStr = '0' + date.day.toString();
        //     }
        //     stringBuffer
        //       ..write(date.year)
        //       ..write('-')
        //       ..write(monthStr)
        //       ..write('-')
        //       ..write(dayStr);
        //   } else if (widgetEntity.dateTimeType == 'hour') {
        //     stringBuffer..write(DateFormat('yyyy-MM-dd HH:mm').format(date));
        //   }
        //   stateCallback(stringBuffer.toString());
        // });
      },
      child: Container(
        alignment: FractionalOffset.centerLeft,
        child: Text(
          widgetEntity.dateTimeValue,
          softWrap: false,
          style: TextStyle(
              fontSize: Dimens.FONT_SIZE_16,
              color: Colours.text_2222,
              fontWeight: FontWeight.w400),
        ),
      ),
    );
  }

  static Widget selectYearDateYuan(
      WidgetEntity widgetEntity, BuildContext context,
      {Function stateCallback}) {
    return FlatButton(
      color: Colours.gray_f0,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.all(Radius.circular(20)),
      ),
      onPressed: () {
//         DatePicker.showDatePicker(context,
//             minDateTime: DateTime(1970),
//             maxDateTime: DateTime(2025),
//             locale: DateTimePickerLocale.zh_cn,
//             dateFormat: widgetEntity.dateTimeType == 'year'
//                 ? 'yyyy'
//                 : 'yyyy,MM,dd', onConfirm: (date, selectedIndex) {
//           StringBuffer stringBuffer = new StringBuffer();
//           if (widgetEntity.dateTimeType == 'year') {
//             stringBuffer.write(date.year.toString());
//           } else if (widgetEntity.dateTimeType == 'day') {
//             String monthStr = date.month.toString();
//             if (monthStr.length == 1) {
//               monthStr = '0' + date.month.toString();
//             }
//             String dayStr = date.day.toString();
//             if (dayStr.length == 1) {
//               dayStr = '0' + date.day.toString();
//             }
//             stringBuffer
//               ..write(date.year)
//               ..write('-')
//               ..write(monthStr)
//               ..write('-')
//               ..write(dayStr);
//           }
//           stateCallback(stringBuffer.toString());
// //          setState(() {
// //            widgetEntity.dateTimeValue = date.year.toString();
// //          });
//         });
      },
      child: Container(
        alignment: FractionalOffset.center,
        child: Text(
          widgetEntity.title == null ? '请选择' : widgetEntity.title,
          softWrap: false,
          style: TextStyle(
              color: Colours.text_2222,
              fontSize: Dimens.FONT_SIZE_14,
              fontWeight: FontWeight.w400),
        ),
      ),
    );
  }

  static List<DropdownMenuItem> getListData(
      List<CommunitySeletionResultEntity> list) {
    List<DropdownMenuItem> items = List();
    Set<String> entity = Set();
    entity.add('请选择');
    for (var CommunitySeletionResultList in list) {
      entity.add(CommunitySeletionResultList.name);
    }
    for (var str in entity) {
      DropdownMenuItem dropdownMenuItem = DropdownMenuItem(
        child: getTextColorView(str, Colours.text_2222, Dimens.FONT_SIZE_16),
        value: str,
      );
      items.add(dropdownMenuItem);
      // LogUtil.e(str, tag: 'getListData......');
    }
    return items;
  }

  static WidgetEntity initSpinner(
      String title, String level, List list, String value) {
    WidgetEntity widgetEntity = WidgetEntity();
    widgetEntity.title = title;
    widgetEntity.spinnerLevel = level;
    widgetEntity.spinnerList = list;
    widgetEntity.spinnerValue = (null == value || value.isEmpty)
        ? '请选择'
        : initSpinnerValue(list, value);
    widgetEntity.type = 'Spinner';
    widgetEntity.fristValue = Utils.reTextNull(value);
    return widgetEntity;
  }

  static String initSpinnerValue(
      List<CommunitySeletionResultEntity> pdSVOList, String value) {
    String reult = '';
    List<String> list = [];
    for (var pdSVO in pdSVOList) {
      list.add(pdSVO.name);
      if (null != value &&
          value.isNotEmpty &&
          (value == pdSVO.id || value == pdSVO.code || value == pdSVO.name)) {
        reult = pdSVO.name;
      }
    }
    return reult.isEmpty ? '请选择' : reult;
  }

  static WidgetEntity initTimeView(String title, String type, String value) {
    WidgetEntity widgetEntity = WidgetEntity();
    widgetEntity.title = title;
    widgetEntity.dateTimeValue = value;
    widgetEntity.dateTimeType = type;
    widgetEntity.type = 'DatePicker';
    widgetEntity.fristValue = Utils.reTextNull(value);
    return widgetEntity;
  }

  static Widget getCheckboxView(SelectiontEntity entity,
      {bool isShow: true,
      Color contentColor: Colours.text_33,
      Color textColor: Colours.text_2222,
      double verticalPadding: 12,
      double horizontalPadding: 16,
      Function blackCall}) {
    // LogUtil.e(entity.title, tag: 'getCheckboxView...');
    return Container(
      padding: EdgeInsets.symmetric(
          horizontal: horizontalPadding, vertical: verticalPadding),
      child: Row(children: <Widget>[
        ObjectUtil.isEmptyString(entity.title)
            ? Container()
            : WidgetUtils.getTextColorView(
                entity.title, textColor, Dimens.FONT_SIZE_16),
        Expanded(
          child: checkboxView(
            entity,
            isShow: isShow,
            contentColor: contentColor,
            verticalPadding: verticalPadding,
            blackCall: blackCall,
          ),
        ),
      ]),
    );
  }

  static Widget getCheckboxIocnView(SelectiontEntity entity,
      {bool isShow: true,
      bool isCheckbox: false,
      Color contentColor: Colours.text_33,
      Color textColor: Colours.text_2222,
      double textSize: Dimens.FONT_SIZE_12,
      double verticalPadding: 12,
      double horizontalPadding: 12,
      Color iconsColor,
      int titleExp: 0,
      int contentExp: 1,
      Function blackCall}) {
    // LogUtil.e(entity.title, tag: 'getCheckboxView...');
    return GestureDetector(
      onTap: () {
        blackCall();
      },
      child: Container(
        padding: EdgeInsets.symmetric(
            horizontal: horizontalPadding, vertical: verticalPadding),
        child: Row(children: <Widget>[
          Expanded(
              flex: titleExp,
              child: ObjectUtil.isEmptyString(entity.value)
                  ? Container()
                  : WidgetUtils.getTextColorView(
                      entity.value, textColor, textSize)),
          SizedBox(
            width: 4,
          ),
          Expanded(
              flex: contentExp,
              child: Row(
                children: <Widget>[
                  Icon(
                    entity.isSelect
                        ? (isCheckbox
                            ? Icons.check_box
                            : Icons.radio_button_checked)
                        : (isCheckbox
                            ? Icons.check_box_outline_blank
                            : Icons.radio_button_unchecked),
                    color: null == iconsColor ? Colours.themeColor : iconsColor,
                    size: 18,
                  ),
                  SizedBox(
                    width: 4,
                  ),
                  ObjectUtil.isEmptyString(entity.title)
                      ? Container()
                      : Expanded(
                          child: WidgetUtils.getTextColorView(
                              entity.title, textColor, textSize),
                        ),
                ],
              )),
        ]),
      ),
    );
  }

  static Widget checkboxView(SelectiontEntity entity,
      {bool isShow: true,
      Color contentColor: Colours.text_33,
      Color textColor: Colours.text_2222,
      double verticalPadding: 0,
      Function blackCall}) {
    //  LogUtil.e(entity.title, tag: 'getCheckboxView...');
    return CheckboxListTile(
      controlAffinity: ListTileControlAffinity.leading,
      activeColor: Colours.themeColor,
      // secondary: const Icon(Icons.shutter_speed),
      title: ObjectUtil.isEmptyString(entity.value)
          ? Container()
          : WidgetUtils.getTextColorView(
              entity.value, Colors.black, Dimens.FONT_SIZE_16),
      value: entity.isSelect,
      onChanged: (bool value) {
        blackCall(value);
      },
    );
  }

  static Widget crteateRaisedButton(String title,
      {Color textColor: Colors.white, VoidCallback buttonListener}) {
    return RaisedButton(
      elevation: 0.0,
      shape:
          RoundedRectangleBorder(borderRadius: BorderRadius.circular(6) //设置圆角
              ),
      child: getTextColorView(title, Colours.title_white, Dimens.FONT_SIZE_13),
      onPressed: buttonListener,
      textColor: textColor,
      color: Colours.themeColor,
    );
  }

  static Widget selectCity(
      String title, Map<String, dynamic> cityAdress, BuildContext context,
      {Function adressCallBlack,
      bool isHide: false,
      textSize: Dimens.FONT_SIZE_16}) {
    return Container(
      padding: const EdgeInsets.symmetric(vertical: 12),
      color: Colors.white,
      child: Column(
        children: <Widget>[
          ObjectUtil.isEmptyString(title)
              ? GestureDetector(
                  onTap: () {
                    _showCity(context).then((data) {
                      if (ObjectUtil.isEmpty(data)) {
                        return;
                      }
                      adressCallBlack(data);
                    });
                  },
                  child: Container(
                    color: Colors.transparent,
                    padding: const EdgeInsets.only(left: 16),
                    child: ObjectUtil.isEmptyString(cityAdress['adress'])
                        ? Container()
                        : WidgetUtils.getTextColorView(
                            cityAdress['adress'], Colours.text_2222, textSize),
                  ),
                )
              : Row(
                  children: <Widget>[
                    Expanded(
                      child: Container(
                        padding: const EdgeInsets.only(left: 16),
                        alignment: FractionalOffset.centerLeft,
                        child: WidgetUtils.getTextColorView(
                            title, Colours.text_2222, textSize),
                      ),
                      flex: 1,
                    ),
                    Expanded(
                      child: GestureDetector(
                        onTap: () {
                          _showCity(context).then((data) {
                            if (ObjectUtil.isEmpty(data)) {
                              return;
                            }
                            adressCallBlack(data);
                          });
                        },
                        child: Container(
                          color: Colors.transparent,
                          padding: const EdgeInsets.only(left: 16),
                          child: WidgetUtils.getTextColorView(
                              ObjectUtil.isEmptyString(cityAdress['adress'])
                                  ? '请选择'
                                  : cityAdress['adress'],
                              Colours.text_2222,
                              textSize),
                        ),
                      ),
                      flex: 2,
                    ),
                  ],
                ),
          Offstage(
            offstage: isHide,
            child: Padding(
              padding: const EdgeInsets.only(top: 12),
              child: WidgetUtils.drawDivider(),
            ),
          ),
        ],
      ),
    );
  }

  static Future _showCity(BuildContext context) async {
    Map<String, dynamic> _cityAdress = {};
    Result result;
    if (ObjectUtil.isEmptyMap(BaseConstant.citysData) ||
        ObjectUtil.isEmptyMap(BaseConstant.provincesData)) {
      result = await CityPickers.showCityPicker(
        context: context,
      );
    } else {
      result = await CityPickers.showCityPicker(
        context: context,
        citiesData: BaseConstant.citysData,
        provincesData: BaseConstant.provincesData,
      );
    }
    StringBuffer stringBuffer = StringBuffer();
    stringBuffer
      ..write(result.provinceName)
      ..write('  ')
      ..write(result.cityName)
      ..write('  ')
      ..write(result.areaName);
    _cityAdress['adress'] = stringBuffer.toString();
    _cityAdress['provinceId'] = result.provinceId;
    _cityAdress['cityId'] = result.cityId;
    _cityAdress['areaId'] = result.areaId;
    _cityAdress['provinceName'] = result.provinceName;
    _cityAdress['cityName'] = result.cityName;
    _cityAdress['areaName'] = result.areaName;
    return _cityAdress;
  }

  // static Widget starView(String title, String ratingValue,
  //     {Function starValueCall}) {
  //   return Row(
  //     children: <Widget>[
  //       SizedBox(
  //         width: 16,
  //       ),
  //       WidgetUtils.getTextColorView(
  //           title, Colours.text_2222, Dimens.FONT_SIZE_16),
  //       SizedBox(
  //         width: 8,
  //       ),
  //       SponRatingWidget(
  //         value: 5,
  //         size: 30,
  //         padding: 5,
  //         selectAble: true,
  //         onRatingUpdate: (value) {
  //           ratingValue = value;
  //           starValueCall(ratingValue);
  //         },
  //         //最大的评分数
  //         maxRating: 5,
  //         //星星总数
  //         count: 5,
  //       ),
  //       SizedBox(
  //         width: 8,
  //       ),
  //       WidgetUtils.getTextColorView(
  //           value(ratingValue), Colours.text_2222, Dimens.FONT_SIZE_16),
  //     ],
  //   );
  // }

  static String value(ratingValue) {
    if (ratingValue == null) {
      return '评分：5分';
    } else {
      return '评分：$ratingValue分';
    }
  }

  static Future attrubuteDialogFuture(
      BuildContext context, StatefulWidget statefulWidget,
      {bool barrierDismissible: false}) async {
    return showDialog(
        barrierDismissible: barrierDismissible,
        context: context,
        builder: (context) {
          return statefulWidget;
        });
  }

  //设置沉浸式
  static setOverlayStyle() {
    if (Platform.isAndroid) {
      // 以下两行 设置android状态栏为透明的沉浸。写在组件渲染之后，是为了在渲染后进行set赋值，覆盖状态栏，写在渲染之前MaterialApp组件会覆盖掉这个值。
      SystemUiOverlayStyle systemUiOverlayStyle =
          SystemUiOverlayStyle(statusBarColor: Colors.transparent);
      SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
    } else {
      SystemUiOverlayStyle systemUiOverlayStyle = SystemUiOverlayStyle(
          statusBarColor: Colors.transparent,
          statusBarIconBrightness: Brightness.light);
      SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
    }
  }

  static Widget wrapListView(List<SelectiontEntity> list,
      {Function checkBoxCall}) {
    return Container(
      alignment: Alignment.centerLeft,
      padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
      child: Wrap(
        direction: Axis.horizontal,
        alignment: WrapAlignment.start,
        crossAxisAlignment: WrapCrossAlignment.start,
        children: list.map((SelectiontEntity entity) {
          return _departmentName(list, entity, checkBoxCall: checkBoxCall);
        }).toList(),
      ),
    );
  }

  static Widget _departmentName(
      List<SelectiontEntity> list, SelectiontEntity entity,
      {Function checkBoxCall}) {
    return GestureDetector(
      onTap: (() {
        for (var item in list) {
          item.isSelect = false;
        }
        entity.isSelect = !entity.isSelect;
        checkBoxCall(list);
      }),
      child: Padding(
        padding: const EdgeInsets.only(right: 16, top: 8),
        child: Chip(
          backgroundColor:
              entity.isSelect ? Colours.themeColor : Colours.gray_f0,
          shape:
              RoundedRectangleBorder(borderRadius: BorderRadius.circular(6.0)),
          labelPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
          label: WidgetUtils.getTextColorView(
              entity.title,
              entity.isSelect ? Colors.white : Colours.themeColor,
              Dimens.FONT_SIZE_16),
        ),
      ),
    );
  }

  // static Widget marqueeWidget(String text,
  //     {Axis scrollAxis: Axis.vertical,
  //     double fontSize: 16.0,
  //     Color color: Colours.text_2222}) {
  //   return Container(
  //     height: 42,
  //     child: MarqueeWidget(
  //       text: text,
  //       textStyle: TextStyle(fontSize: fontSize, color: color),
  //       scrollAxis: scrollAxis,
  //     ),
  //   );
  // }

  static Widget searchView(
      BuildContext context, TextEditingController controllerSreach,
      {String title, Function searchCall}) {
    return Container(
      height: 50.0,
      width: double.infinity,
      padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8),
      decoration: new BoxDecoration(
        color: Colours.themeColor,
      ),
      child: Material(
          color: Colors.white,
          borderRadius: BorderRadius.circular(18.0),
          child: Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              Container(
                margin: const EdgeInsets.symmetric(horizontal: 16.0),
                child: Icon(
                  Icons.search,
                  color: Colours.themeColor,
                  size: 24,
                ),
              ),
              Expanded(
                flex: 1,
                child: Container(
                  child: TextField(
                      style: TextStyle(
                        fontSize: 16.0,
                        color: Colours.text_gray,
                      ),
                      autofocus: false,
                      cursorColor: Colours.themeColor,
                      decoration: InputDecoration(
                        contentPadding: EdgeInsets.only(bottom: 13),
                        border: InputBorder.none,
                        hintText: '请输入您要查找的关键词',
                      ),
                      controller: controllerSreach, //设置controller
                      // textAlign: TextAlign.center,
                      onChanged: (v) {}),
                ),
              ),
              GestureDetector(
                child: Container(
                  margin: const EdgeInsets.symmetric(horizontal: 16.0),
                  child: WidgetUtils.getTextColorView(
                      '搜索', Colours.themeColor, Dimens.FONT_SIZE_16),
                ),
                onTap: (() {
                  String keyWord = controllerSreach.text;
                  if (ObjectUtil.isEmptyString(keyWord)) {
                    BotToast.showText(text: '请输入您要查找的关键词');
                    return;
                  }
                  if (ObjectUtil.isEmptyString(title) || '搜索' != title) {
                    // RouteUtil.goParameter(
                    //     context,
                    // SearchPage(
                    //   title: '搜索',
                    //   keyWord: keyWord,
                    // ));
                  } else {
                    if (null != searchCall) {
                      //处在搜索界面
                      searchCall();
                    }
                  }
                }),
              ),
            ],
          )),
    );
  }

  static Widget emptyView(BuildContext context,
      {MainAxisAlignment mainAxisAlignment: MainAxisAlignment.center,
      bool isSearch: false}) {
    return Container(
      padding: EdgeInsets.symmetric(vertical: 16),
      child: Column(
        mainAxisAlignment: mainAxisAlignment,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          Padding(
              padding: EdgeInsets.only(
                  top: isSearch ? MediaQuery.of(context).size.height / 4 : 0),
              child: WidgetUtils.buildNetworkImageView(
                'https://lizhengyouxuan.oss-cn-shanghai.aliyuncs.com/lizhengyouxuan/other/contact_search.png',
              )),
          Padding(
            padding: const EdgeInsets.only(top: 24),
            child: WidgetUtils.getTextColorView(
                '暂无数据～', Colours.text_91, Dimens.FONT_SIZE_16),
          ),
        ],
      ),
    );
  }

  static Widget marqueeWidget(String text,
      {Axis scrollAxis: Axis.vertical,
      double fontSize: 16.0,
      Color color: Colours.text_2222}) {
    return Container(
      height: 42,
      child: MarqueeWidget(
        text: text,
        textStyle: TextStyle(fontSize: fontSize, color: color),
        scrollAxis: scrollAxis,
      ),
    );
  }
}
